﻿using System.Windows;
using System.Windows.Interactivity;
#if (!WINRT)
using System.Windows.Controls;
using System.Windows.Interactivity;
#else
using nRoute.Behaviors.Interactivity;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
#endif

namespace nRoute.Behaviors
{
#if (!WINRT)
    [TypeConstraintAttribute(typeof(DependencyObject))]
#endif
    public class TargetedSetFocusAction
#if (SILVERLIGHT || WINRT)
        : TargetedTriggerAction<Control>
#else
        : TargetedTriggerAction<UIElement>
#endif
    {
        protected override void Invoke(object parameter)
        {
#if (WINRT)
            if (Target != null) ((Control)Target).Focus(FocusState.Programmatic);
#else
            if (Target != null) Target.Focus();
#endif
        }
    }
}
